From 98fd1a41ef7f38c12a47178b42c68332ed9eff55 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Mon, 3 Nov 2003 11:19:13 +0000 Subject: [PATCH] bitkeeper revision 1.551 (3fa639b1Ozv5gqMWisVgyFIergU8DQ) hypervisor.h, dom0_ops.h, dom0_ops.c, dom0_defs.h: Add a version number to the dom0_op interface, to prevent crashes and hangs with out-of-date user tools. --- tools/internal/dom0_defs.h | 7 +++++++ xen/common/dom0_ops.c | 3 +++ xen/include/hypervisor-ifs/dom0_ops.h | 8 ++++++++ xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h | 1 + 4 files changed, 19 insertions(+) diff --git a/tools/internal/dom0_defs.h b/tools/internal/dom0_defs.h index 1c271534ec..bea8981bee 100644 --- a/tools/internal/dom0_defs.h +++ b/tools/internal/dom0_defs.h @@ -85,6 +85,8 @@ static inline int do_dom0_op(dom0_op_t *op) int ret = -1; privcmd_hypercall_t hypercall; + op->interface_version = DOM0_INTERFACE_VERSION; + hypercall.op = __HYPERVISOR_dom0_op; hypercall.arg[0] = (unsigned long)op; @@ -95,7 +97,12 @@ static inline int do_dom0_op(dom0_op_t *op) } if ( do_xen_hypercall(&hypercall) < 0 ) + { + if ( errno == EINVAL ) + fprintf(stderr, "Dom0 operation failed -- need to" + " rebuild the user-space tool set?\n"); goto out2; + } ret = 0; diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 5358f19b50..17dbf1d4de 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -92,6 +92,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op) if ( copy_from_user(&op, u_dom0_op, sizeof(op)) ) return -EFAULT; + if ( op.interface_version != DOM0_INTERFACE_VERSION ) + return -EINVAL; + switch ( op.cmd ) { diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 639860dd8b..ff07461f8b 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -12,6 +12,13 @@ #include "hypervisor-if.h" +/* + * Make sure you increment the interface version whenever you modify this file! + * This makes sure that old versions of dom0 tools will stop working in a + * well-defined way (rather than crashing the machine, for instance). + */ +#define DOM0_INTERFACE_VERSION 0xAAAA0001 + /* * The following is all CPU context. Note that the i387_ctxt block is filled @@ -178,6 +185,7 @@ typedef struct dom0_settime_st typedef struct dom0_op_st { unsigned long cmd; + unsigned long interface_version; /* DOM0_INTERFACE_VERSION */ union { dom0_createdomain_t createdomain; diff --git a/xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h b/xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h index 9450f76f3c..fedd5d9455 100644 --- a/xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h +++ b/xenolinux-2.4.22-sparse/include/asm-xeno/hypervisor.h @@ -265,6 +265,7 @@ static inline int HYPERVISOR_exit(void) static inline int HYPERVISOR_dom0_op(void *dom0_op) { int ret; + op->interface_version = DOM0_INTERFACE_VERSION; __asm__ __volatile__ ( TRAP_INSTR : "=a" (ret) : "0" (__HYPERVISOR_dom0_op), -- 2.30.2